/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Dao.SistemaDAO;
import Modelo.Enfermeiro;
import Modelo.Especialidade;
import Modelo.Login;
import Util.PAPUtil;
import java.util.ArrayList;

/**
 *
 * @author Sergio
 */
public class CadEnfermeiro extends javax.swing.JFrame {

    PAPUtil papUtil = new PAPUtil();
    SistemaDAO sisDAO = new SistemaDAO();
    Enfermeiro enf = new Enfermeiro();
    Login l;

    /**
     * Creates new form CadEnfermeiro
     */
    public CadEnfermeiro(Object o) {
        initComponents();
        this.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); //Maximiza a tela
        jTxtCodigoEnf.setVisible(false);
    }

    public CadEnfermeiro(Enfermeiro en) {
        initComponents();
        this.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); //Maximiza a tela
        jTxtCodigoEnf.setVisible(false);
        this.enf = en;
        mostra();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jPnEnfermeiro = new javax.swing.JPanel();
        jTxtNome = new javax.swing.JTextField();
        jTxtRG = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLErrMsg = new javax.swing.JLabel();
        jTxtEndereco = new javax.swing.JTextField();
        jBtSalvar = new javax.swing.JButton();
        jBtCancelar = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jTxtCoren = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTxtFormCPF = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTxtFormTelefone = new javax.swing.JFormattedTextField();
        jLabel8 = new javax.swing.JLabel();
        jTxtCodigoEnf = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jTxtUsuario = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jTxtSenha = new javax.swing.JTextField();
        jTxtCodigo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jMbPrincipal = new javax.swing.JMenuBar();
        jMnAcoes = new javax.swing.JMenu();
        jMiCadastrar = new javax.swing.JMenuItem();
        jMiSair = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadstro de enfermeiro");

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jPnEnfermeiro.setBackground(new java.awt.Color(255, 255, 255));
        jPnEnfermeiro.setBorder(javax.swing.BorderFactory.createTitledBorder("Enfermeiro"));

        jTxtRG.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTxtRGKeyTyped(evt);
            }
        });

        jLabel1.setText("Nome:");

        jLabel3.setText("RG:");

        jLErrMsg.setText("Hostipal Reat In Peace");

        jBtSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/V.png"))); // NOI18N
        jBtSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtSalvarActionPerformed(evt);
            }
        });

        jBtCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/X.png"))); // NOI18N
        jBtCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtCancelarActionPerformed(evt);
            }
        });

        jLabel6.setText("CPF:");

        jTxtCoren.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTxtCorenKeyTyped(evt);
            }
        });

        jLabel5.setText("Telefone:");

        try {
            jTxtFormCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel4.setText("Coren:");

        jLabel2.setText("Endereço:");

        try {
            jTxtFormTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel8.setText("Código:");

        jTxtCodigoEnf.setBackground(new java.awt.Color(204, 204, 204));
        jTxtCodigoEnf.setEditable(false);
        jTxtCodigoEnf.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Login"));

        jLabel10.setText("Usuário:");

        jLabel11.setText("Senha:");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTxtUsuario, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(jTxtSenha))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTxtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jTxtCodigo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPnEnfermeiroLayout = new javax.swing.GroupLayout(jPnEnfermeiro);
        jPnEnfermeiro.setLayout(jPnEnfermeiroLayout);
        jPnEnfermeiroLayout.setHorizontalGroup(
            jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnEnfermeiroLayout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel8))
                .addGap(10, 10, 10)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTxtRG)
                    .addComponent(jTxtNome, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxtCodigoEnf, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnEnfermeiroLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPnEnfermeiroLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLErrMsg, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPnEnfermeiroLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTxtEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPnEnfermeiroLayout.createSequentialGroup()
                        .addGap(13, 13, 13)
                        .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTxtFormCPF)
                            .addComponent(jTxtCoren, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTxtFormTelefone)))
                .addContainerGap(151, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPnEnfermeiroLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jBtCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBtSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(163, 163, 163))
        );
        jPnEnfermeiroLayout.setVerticalGroup(
            jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPnEnfermeiroLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTxtCodigoEnf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTxtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTxtRG, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(11, 11, 11)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtCoren, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jTxtFormTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTxtFormCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPnEnfermeiroLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBtSalvar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBtCancelar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLErrMsg)
                .addContainerGap())
        );

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/Simbolo_med1.jpg"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(57, 57, 57)
                .addComponent(jLabel7)
                .addGap(215, 215, 215)
                .addComponent(jPnEnfermeiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(662, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addComponent(jLabel7))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jPnEnfermeiro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(49, Short.MAX_VALUE))
        );

        jMnAcoes.setText("Ações");

        jMiCadastrar.setText("Cadastrar");
        jMiCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMiCadastrarActionPerformed(evt);
            }
        });
        jMnAcoes.add(jMiCadastrar);

        jMiSair.setText("Sair");
        jMiSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMiSairActionPerformed(evt);
            }
        });
        jMnAcoes.add(jMiSair);

        jMbPrincipal.add(jMnAcoes);

        setJMenuBar(jMbPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtSalvarActionPerformed
        if (!verificaBranco()) {
            return;
        }

        Enfermeiro enf = new Enfermeiro();
        enf.setNome(jTxtNome.getText());
        enf.setEndereco(jTxtEndereco.getText());
        enf.setRg(jTxtRG.getText());
        enf.setCpf(jTxtFormCPF.getText());
        enf.setTelefone(jTxtFormTelefone.getText());
        enf.setCorem(jTxtCoren.getText());

        if (!jTxtCodigoEnf.getText().trim().equals("")) {
            enf.setIdenfermeiro(Integer.parseInt(jTxtCodigoEnf.getText()));
        }

        //enf.setLoginIdlogin(WIDTH);

        sisDAO.addUpObjeto(enf);
 
        int ultCod = (int) sisDAO.ultimoCodigo("Modelo.Medico", "idmedico");

        l = new Login();

        l.setIdRelacao(ultCod);
        l.setSenha(jTxtSenha.getText());
        l.setUsuario(jTxtUsuario.getText());
        l.setCategoria(2);

        if (!jTxtCodigo.getText().trim().equals("")) {
            l.setIdlogin(Integer.parseInt(jTxtCodigo.getText()));
        }

        sisDAO.addUpObjeto(l);

        this.dispose();


    }//GEN-LAST:event_jBtSalvarActionPerformed

    private void jMiCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMiCadastrarActionPerformed
        if (!verificaBranco()) {
            return;
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jMiCadastrarActionPerformed

    private void jBtCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtCancelarActionPerformed
        this.setVisible(false);
        this.dispose();
    }//GEN-LAST:event_jBtCancelarActionPerformed

    private void jMiSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMiSairActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
        this.dispose();
    }//GEN-LAST:event_jMiSairActionPerformed

    private void jTxtCorenKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtCorenKeyTyped
        if (!papUtil.somenteNumero(evt, '0')) {
            evt.consume();
        }
        if (!papUtil.tamanhoMaximo(10, jTxtCoren.getText().length())) {
            evt.consume();
        }
    }//GEN-LAST:event_jTxtCorenKeyTyped

    private void jTxtRGKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtRGKeyTyped
        if (!papUtil.somenteNumero(evt, '0')) {
            evt.consume();
        }
        if (!papUtil.tamanhoMaximo(10, jTxtRG.getText().length())) {
            evt.consume();
        }
    }//GEN-LAST:event_jTxtRGKeyTyped

    public void cadastrar() {
        jLErrMsg.setText("Enfermeiro cadastrado com sucesso!");
    }

    private boolean verificaBranco() {
        if (jTxtNome.getText().trim().equals("")) {
            jLErrMsg.setText("Campo nome do enfermeiro é obrigatorio.");
            return false;
        }
        if (jTxtRG.getText().equals("")) {
            jLErrMsg.setText("Campo RG é obrigatorio.");
            return false;
        }
        if (jTxtEndereco.getText().trim().equals("")) {
            jLErrMsg.setText("Campo endereço é obrigatorio.");
            return false;
        }
        if (jTxtCoren.getText().trim().equals("")) {
            jLErrMsg.setText("Campo Coren é obrigatorio.");
            return false;
        }
        if (jTxtFormTelefone.getText().equals("(  )     .    ")) {
            jLErrMsg.setText("Campo Telefone é obrigatorio.");
            return false;
        }
        if (jTxtFormCPF.getText().trim().equals("   .   .   -  ")) {
            jLErrMsg.setText("Campo convênio é obrigatorio.");
            return false;
        }

        return true;
    }

    private void mostra() {
        jTxtCodigoEnf.setText(String.valueOf(enf.getIdenfermeiro()));
        jTxtNome.setText(enf.getNome());
        jTxtFormCPF.setText(enf.getCpf().toString());
        jTxtEndereco.setText(enf.getEndereco());
        jTxtCoren.setText(enf.getCorem());
        jTxtFormTelefone.setText(enf.getTelefone());
        jTxtRG.setText(enf.getRg());

        ArrayList<Login> arrayLogin = new ArrayList<>();

        arrayLogin = (ArrayList<Login>) sisDAO.listaCondicao("Modelo.Login",
                String.valueOf(enf.getIdenfermeiro()), null, null, "idRelacao", 3);

        if (!(arrayLogin == null)) {

            for (Login lo : arrayLogin) {
                if (lo.getCategoria() == 2) {
                    jTxtUsuario.setText(lo.getUsuario());
                    jTxtSenha.setText(lo.getSenha());
                    jTxtCodigo.setText(String.valueOf(lo.getIdlogin()));
                }
            }
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtCancelar;
    private javax.swing.JButton jBtSalvar;
    private javax.swing.JLabel jLErrMsg;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenuBar jMbPrincipal;
    private javax.swing.JMenuItem jMiCadastrar;
    private javax.swing.JMenuItem jMiSair;
    private javax.swing.JMenu jMnAcoes;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPnEnfermeiro;
    private javax.swing.JTextField jTxtCodigo;
    private javax.swing.JTextField jTxtCodigoEnf;
    private javax.swing.JTextField jTxtCoren;
    private javax.swing.JTextField jTxtEndereco;
    private javax.swing.JFormattedTextField jTxtFormCPF;
    private javax.swing.JFormattedTextField jTxtFormTelefone;
    private javax.swing.JTextField jTxtNome;
    private javax.swing.JTextField jTxtRG;
    private javax.swing.JTextField jTxtSenha;
    private javax.swing.JTextField jTxtUsuario;
    // End of variables declaration//GEN-END:variables
}
